package com.maxmlr.music.song.service.transfer;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.maxmlr.music.admin.entity.User;
import com.maxmlr.music.common.util.DateUtil;
import com.maxmlr.music.song.entity.Song;
import com.maxmlr.music.song.param.SongInfoParam;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @ClassName SingerTransfer
 * @Description TODO
 * @Author maxiao
 * @Date 2020/6/7 下午10:24
 * @Version V1.0
 */
@Component
public class SongTransfer {

    public SongInfoParam po2SongInfoParam(Song song) {
        SongInfoParam songInfoParam = new SongInfoParam();
        songInfoParam.setId(song.getId());
        songInfoParam.setSpecialId(song.getSpecialId());
        songInfoParam.setSingerId(song.getSingerId());
        songInfoParam.setSongName(song.getSongName());
        //songInfoParam.setHeadImg();
        songInfoParam.setHeadImgId(song.getHeadImgId());
        songInfoParam.setMp3Id(song.getMp3Id());
        songInfoParam.setMvId(song.getMvId());
        songInfoParam.setSongType(song.getSongType());
        songInfoParam.setRanking(song.getRanking());
        //songInfoParam.setNation();
        songInfoParam.setReleaseDate(DateUtil.getDateTimeStr(song.getReleaseDate()));
        songInfoParam.setCreateUserId(song.getCreateUserId());
        songInfoParam.setUpdateUserId(song.getUpdateUserId());
        songInfoParam.setCreateTime(DateUtil.getDateTimeStr(song.getCreateTime()));
        songInfoParam.setUpdateTime(DateUtil.getDateTimeStr(song.getUpdateTime()));
        return songInfoParam;
    }

    public Song po2Song(SongInfoParam param, User adminUser) {
        Date date = DateUtil.getDate();
        Song song = po2Song(param);
        song.setCreateUserId(adminUser.getId());
        song.setUpdateUserId(adminUser.getId());
        song.setReleaseDate(date);
        song.setCreateTime(date);
        song.setUpdateTime(date);
        return song;
    }
    public Song po2Song(SongInfoParam param) {
        Song song = new Song();
        song.setSpecialId(param.getSpecialId());
        song.setSingerId(param.getSingerId());
        song.setSongName(param.getSongName());
        song.setHeadImgId(param.getHeadImgId());
        song.setMp3Id(param.getMp3Id());
        song.setMvId(param.getMvId());
        song.setSongType(param.getSongType());
        song.setRanking(param.getRanking());
        return song;
    }

    public Song fullSong(Song song, SongInfoParam param, User adminUser) {
        Date date = DateUtil.getDate();
        song.setSpecialId(param.getSpecialId());
        song.setSingerId(param.getSingerId());
        song.setSongName(param.getSongName());
        song.setHeadImgId(param.getHeadImgId());
        song.setMp3Id(param.getMp3Id());
        song.setMvId(param.getMvId());
        song.setSongType(param.getSongType());
        song.setRanking(param.getRanking());
        song.setUpdateUserId(adminUser.getId());
        song.setUpdateTime(date);
        return song;
    }

    public Page<SongInfoParam> po2PageSongInfoParam(Page<Song> page) {
        Page<SongInfoParam> page1 = new Page<>();
        page1.setTotal(page.getTotal());
        page1.setSize(page.getSize());
        page1.setCurrent(page.getCurrent());
        page1.setOrders(page.getOrders());
        return page1;
    }
}
